package apdate

import activity.TalkActivity
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.wd.common.bean.TalkBean
import com.wd.rim.R

class TalkApdate(var context: Context, val list: TalkBean)
    :RecyclerView.Adapter<TalkApdate.ViewHolder>(){
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val inflate = LayoutInflater.from(context).inflate(R.layout.item_talk, parent, false)
        return ViewHolder(inflate)
    }

    override fun getItemCount(): Int {
        return list.result.hotTopicList.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.name.text=list.result.hotTopicList.get(position).title
        holder.itemView.setOnClickListener {
            val intent = Intent()
            intent.putExtra("HotId",list.result.hotTopicList.get(position).hotId)
            intent.putExtra("name",list.result.hotTopicList.get(position).title)
            intent.setClass(context,TalkActivity::class.java)
            context.startActivity(intent)
        }

    }

    class ViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){

        val name:TextView
        init {
             name = itemView.findViewById<TextView>(R.id.name)
        }
    }
}